

var gulp = require('gulp');
var uglify = require('gulp-uglify');
var gzip = require('gulp-gzip');

gulp.task('gzip', function () {
  gulp.src('./src/*.js')
    .pipe(uglify())
    .pipe(gzip({
      threshold: '1kb',
      // gzipOptions: { level: 9 }
    }))
    .pipe(gulp.dest('./dist'));
});

/** 进阶 */
/**
    var del = require('del');
    var gulp = require('gulp');
    var gzip = require('../../index');

    var config = {
      threshold: '1kb'
    };

    gulp.task('clean', function (cb) {
      return del('tmp', cb);
    });

    gulp.task('small', function () {
      return gulp.src('../files/small.txt')
        .pipe(gzip(config))
        .pipe(gulp.dest('tmp'));
    });

    gulp.task('big', function () {
      return gulp.src('../files/big.txt')
        .pipe(gzip(config))
        .pipe(gulp.dest('tmp'));
    });

    gulp.task('large', function () {
      return gulp.src('../files/large.txt', { buffer: false })
        .pipe(gzip(config))
        .pipe(gulp.dest('tmp'));
    });

    // gulp default  会执行所有命令
    gulp.task('default', gulp.series('clean', 'small', 'big', 'large'));
 *
 */